package com.lc.midi.keyEvent;


import com.lc.midi.mid.MidiException;

public class MidiKey {
	 private  final  static int KEYMAXID = 128;
	    private  final  static int INSTRUMENTMAXID = 128;

	    /**
	     * 按键Id
	     */
	    private int keyId;
	    /**
	     * 乐器Id
	     */
	    private int instrumentId;
	    /**
	     * 通道
	     */
	    private int pass;

	    public int getInstrumentId() {
	        return instrumentId;
	    }

	    public void setInstrumentId(int instrumentId) throws MidiException {
	        if (instrumentId >= 0 && instrumentId <= INSTRUMENTMAXID)
	            this.instrumentId = instrumentId;
	        else
	            throw new MidiException("乐器id错误");
	    }

	    public int getKeyId() {
	        return keyId;
	    }

	    public void setKeyId(int keyId) throws MidiException{
	        if (keyId >= 0 && keyId <= KEYMAXID)
	            this.keyId = keyId;
	        else
	            throw new MidiException("按键id错误");
	    }
	    
	    public int getPass() {
			return pass;
		}
	    
	    public void setPass(int pass) throws MidiException {
	    	if (pass >= 0 && pass <= 15)
	    		this.pass = pass;
	    	else
	    		throw new MidiException("pass value error");
		}

	    @Override
	    public boolean equals(Object obj) {
	        if (obj == null)
	            return false;
	        if (obj instanceof MidiKey){
	            MidiKey k = (MidiKey)obj;
	            return k.instrumentId == instrumentId 
	            		&& k.keyId == keyId
	            		&& k.pass == pass;
	        }
	        return false;
	    }
}
